
// export  defineNuxtRouteMiddleware((to, from) => {
//     const store = useAppStore()
//     if (!store.token) {
//         store.$patch({
//              showLogin: true
//          })
//          const path =['/order','/user'].includes(from.path)?'/':from.path
//         return navigateTo({path:path},{
//             replace:true
//         })
//     }
// })

export default ({store, route, redirect}) => {
  if(!store.state.token){
    store.commit('showLogin',true)
    const path =['/order','/user','/shoppingCart'].includes(route.path)?'/':route.path
    return store.$router.push(path)
  }
}
